/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.test.app.validator;
import org.springframework.validation.*;
import com.test.app.form.Contact;

/**
 *
 * @author darshana
 */
public class ContactValidator  implements Validator{

    @Override
    public boolean supports(Class<?> clazz) {
        return Contact.class.isAssignableFrom(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "fname", "Firstname Required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lname", "Lastname Required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "Email Required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tp", "Telephone Required");
    }

}
